//
//  SwitchCell.m
//  ChangChat
//
//  Created by Cocoa on 2019/10/16.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "SwitchCell.h"

@implementation SwitchCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    self.leftTitleLabel = [UILabel k_labelWithFontSize:13 textColor:UIColor.k_t2Color];
    self.switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
    
    [self.contentView addSubview:self.leftTitleLabel];
    [self.contentView addSubview:self.switchView];
    
    [self.leftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_offset(15);
        make.bottom.mas_offset(-15);
    }];
    
    [self.switchView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-15);
        make.centerY.mas_offset(0);
    }];
}

- (void)setModel:(YBContentModel *)model {
    [super setModel:model];
    self.leftTitleLabel.text = model.title;
    [self.switchView setOn:model.selected];
}
@end
